name: CI-macOS

# Controls when the action will run. 
# Triggers the workflow on pull request events but only for the master branch.
on:
  pull_request:
    branches: [ "main" ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build-and-test"
  build-and-test:
    # The type of runner that the job will run on
    runs-on: macos-13

    timeout-minutes: 8

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v4

    - name: Select Xcode
      run: sudo xcode-select -switch /Applications/Xcode_15.2.app
      
    - name: Xcode version
      run: /usr/bin/xcodebuild -version
      
    - name: Build and Test
      run: xcodebuild clean build test -project EssentialFeed.xcodeproj -scheme "CI_macOS" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO  -sdk macosx -destination "platform=macOS" ONLY_ACTIVE_ARCH=YES
